<template>
  <div class="dog">
    <!-- 图出不来所以就用固定的 -->
    <img
      src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
      alt=""
    />
    <p @click="btn" :style="{ background: styCol }">{{ obj.dogName }}</p>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    obj: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      styCol: "",
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    btn() {
      this.styCol = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
      this.$emit("buyDog", this.obj.dogName);
      console.log(this.obj.dogName);
    },
  },
};
</script>

<style scoped>
.dog {
  width: 300px;
  height: 300px;
  float: left;
  margin: 0 10px;
}
img {
  width: 100%;
}
</style>
